/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author A0077454
 */
@Entity
public class SendReminder implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long reminderId;
    @ManyToOne(cascade = {CascadeType.PERSIST}) 
    private Customer customer;
    private String email;
    @OneToMany(cascade = {CascadeType.PERSIST}, mappedBy="reminder")
    private List<Invoice> invoices = new ArrayList<Invoice>();
    private String subject;
    private String content;
    private String signoff;
    private Date sendDate;
    @OneToOne
    private SystemUser sendBy;

    public SendReminder()
    {
        
    }
    
    public void create(String subject, String content, String signoff, Date sendDate) {
        this.subject = subject;
        this.content = content;
        this.signoff = signoff;
        this.sendDate = sendDate;
    }
    
    

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public List<Invoice> getInvoices() {
        return invoices;
    }

    public void setInvoices(List<Invoice> invoices) {
        this.invoices = invoices;
    }

    public Long getReminderId() {
        return reminderId;
    }

    public void setReminderId(Long reminderId) {
        this.reminderId = reminderId;
    }

    public SystemUser getSendBy() {
        return sendBy;
    }

    public void setSendBy(SystemUser sendBy) {
        this.sendBy = sendBy;
    }

    public Date getSendDate() {
        return sendDate;
    }

    public void setSendDate(Date sendDate) {
        this.sendDate = sendDate;
    }

    public String getSignoff() {
        return signoff;
    }

    public void setSignoff(String signoff) {
        this.signoff = signoff;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (reminderId != null ? reminderId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SendReminder)) {
            return false;
        }
        SendReminder other = (SendReminder) object;
        if ((this.reminderId == null && other.reminderId != null) || (this.reminderId != null && !this.reminderId.equals(other.reminderId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.SendReminder[ id=" + reminderId + " ]";
    }
    
    
    //// THINN CHANGES /////
    public void addInvoice(Invoice i)
    {
        this.invoices.add(i);
    }
}
